class Solution
{
public:
    int getWinner(vector<int> &arr, int k)
    {
        int win = 0;
        if (arr[0] < arr[1])
        {
            swap(arr[0], arr[1]);
        }
        int maxNum = arr[0];
        for (int i = 1; i < arr.size(); ++i)
        {
            if (arr[0] > arr[i])
            {
                win += 1;
                if (win >= k)
                {
                    return arr[0];
                }
            }
            else
            {
                win = 1;
                arr[0] = arr[i];
            }
            maxNum = max(maxNum, arr[0]);
        }
        return maxNum;
    }
};